package com.qwqk.controller;
    
    




import com.anwen.mongo.conditions.query.LambdaQueryChainWrapper;
import com.anwen.mongo.model.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import com.qwqk.entity.Delusers;
import com.qwqk.service.DelusersService;
import com.qwqk.config.Result;

/**
 * 控制层
 *
 * @author makejava
 * @since 2024-08-29 13:59:53
 */
@RestController
@Slf4j
@Api(tags = "Delusers类")
@RequestMapping("/delusers")
public class DelusersController {
    @Resource
	private DelusersService delusersService;
    

    @GetMapping("/")
    @ApiOperation("查询所有Delusers")
    public Result<List<Delusers>> findAll(){
        List<Delusers> list = delusersService.list();
        return Result.success(list);
    }

    @GetMapping("/page")
    @ApiOperation("分页查询所有Delusers")
    public Result<PageResult<Delusers>> findAllUser(Integer pageNum, Integer pageSize){
        LambdaQueryChainWrapper<Delusers> queryChainWrapper = delusersService.lambdaQuery();
        PageResult<Delusers> page = delusersService.page(queryChainWrapper, pageNum, pageSize);
        return Result.success(page);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询一条Delusers数据")
    public Result<Delusers> findAll(@PathVariable("id") String id){
        Delusers one =  delusersService.getById(id);
        return Result.success(one);
    }

    @PostMapping("/")
    @ApiOperation("添加Delusers")
    @Transactional
    public Result addUser(@RequestBody Delusers delusers){
        delusersService.save(delusers);
        return Result.success();
    }


    @PutMapping("/")
    @ApiOperation("根据id修改Delusers")
    public Result updateUserById(@RequestBody Delusers delusers){
        delusersService.updateById(delusers);
        return Result.success();
    }



    @DeleteMapping ("/{id}")
    @ApiOperation("根据id删除Delusers")
    public Result deleteUserById(@PathVariable("id")String id){
        delusersService.removeById(id);
        return Result.success();
    }


}
